﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using Maticsoft.DBUtility;

public partial class biz_index : FBasePage
{


    // Methods
    private void initPro()
    {
        int num;
        if ((base.GetCookie("partnerid") == null) || (base.GetCookie("partnerid") == ""))
        {
            base.Response.Redirect("login.aspx");
        }
        StringBuilder builder = new StringBuilder();
        DataSet set = DbHelperSQL.Page(10, this.pager.CurrentPageIndex, "Team", "Partner_id=" + base.GetCookie("partnerid").ToString(), "", "*", out num);
        List<Maticsoft.Model.Team> list = new Maticsoft.BLL.Team().DataTableToList(set.Tables[0]);
        if (set.Tables.Count > 0)
        {
            if (set.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < set.Tables[0].Rows.Count; i++)
                {
                    DataRow row = set.Tables[0].Rows[i];
                    if ((i % 2) != 0)
                    {
                        builder.Append("<tr  id='team-list-id-" + row["id"] + "'>");
                    }
                    else
                    {
                        builder.Append("<tr class=\"alt\"  id='team-list-id-" + row["id"] + "'>");
                    }
                    builder.Append("<td style=\"text-align:left;\"><a class=\"deal-title\" href=\"/team.aspx?id=" + row["ID"].ToString() + "\" target=\"_blank\">" + row["Title"].ToString() + "</a></td>");
                    Maticsoft.Model.Category model = new Maticsoft.BLL.Category().GetModel(int.Parse(row["City_id"].ToString()));
                    if ((int.Parse(row["City_id"].ToString()) != 0) && (model != null))
                    {
                        builder.Append("<td>" + model.Name + "</td>");
                    }
                    else
                    {
                        builder.Append("<td>全部城市</td>");
                    }
                    builder.Append("<td>" + DateTime.Parse(row["Begin_time"].ToString()).ToString("yyyy-MM-dd") + "<br/>" + DateTime.Parse(row["End_time"].ToString()).ToString("yyyy-MM-dd") + "</td>");
                    builder.Append(string.Concat(new object[] { "<td>", row["Now_number"].ToString(), "/", row["Min_number"], "</td>" }));
                    string currency = "";
                    if (base.ASSystem != null)
                    {
                        currency = base.ASSystem.Currency;
                    }
                    builder.Append("<td><span class=\"money\">" + currency + "</span>" + row["Team_price"].ToString() + "<br/><span class=\"money\">" + currency + "</span>" + row["Market_price"].ToString() + "</td>");
                    builder.Append("<td class=\"op\" nowrap><a href=\"/ajax/partner.aspx?action=teamdetail&id=" + row["id"].ToString() + "\" class=\"ajaxlink\">详情</a>");
                    switch (base.GetState(list[i]))
                    {
                        case TeamState.successnobuy:
                        case TeamState.successtimeover:
                        case TeamState.successbuy:
                            builder.Append("｜<a href=\"/biz/down.aspx?id=" + row["id"].ToString() + "\" target=\"_blank\">下载</a></td>");
                            break;
                    }
                    builder.Append("</tr>");
                }
            }
            else
            {
                builder.Append("<tr><td colspan=\"6\">暂无数据！</td></tr>");
            }
        }
        this.ltTeam.Text = builder.ToString();
        this.pager.RecordCount = num;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (!this.Page.IsPostBack)
        {
            this.initPro();
        }
    }

    protected void pager_PageChanged(object sender, EventArgs e)
    {
        this.initPro();
    }

}